package com.yl.androidutilscenter.base

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.yl.androidutilscenter.http.sendRequest

/**
 * @author
 * @description: BaseViewModel
 * @date :2024/3/8
 * @version 1.0.0
 */
abstract class BaseViewModel : ViewModel() {
    //加载中的弹窗
    var isShowLoading = MutableLiveData(false)


    /**
     * ViewModel中发送请求
     */
    open fun <T> sendRequest(
        requestBlock: suspend () -> T, errorCallBack: ((error: Throwable) -> Unit)?= null, callback: (T) -> Unit
    ) {
        viewModelScope.sendRequest(requestBlock, errorCallBack, callback)
    }

}